Neither `PopupMenuBase` nor the `PopupSubMenu` that is used as `menu` of
`PopupSubMenuMenuItem` is destroyable, so the connection needs to be
manually disconnected when the `PopupSubMenu` is destroyed, otherwise
the signal tracker and with it the `PopupSubMenu` is being leaked.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/4426>
(cherry picked from commit
4a0d2e424a4b37ab6264e871a92044c8b83cc5fe)
this.box.insert_child_below(menuItem.menu.actor, beforeItem);
this._connectItemSignals(menuItem);
- menuItem.menu.connectObject('active-changed',
- this._subMenuActiveChanged.bind(this), this);
+ menuItem.menu.connectObject(
+ 'active-changed', this._subMenuActiveChanged.bind(this),
+ 'destroy', () => menuItem.menu.disconnectObject(this),
+ this);
this.connectObject('menu-closed', () => {
menuItem.menu.close(BoxPointer.PopupAnimation.NONE);
}, menuItem);